<?php
namespace Hawk\Controller;
use \Hawk\Controller\IndexController;
class LogController extends IndexController 
{
	/**
     * 操作日志列表
     * @author hawk <2271030162@qq.com>
     * @return mix
     */
	public function lst(){
		if (IS_POST) {
			if(!empty($_POST['user_id'])){
				$search['user_id']=$_POST['user_id'];
				$where['user_name']=$_POST['user_id'];
			}
			if(!empty($_POST['keyword'])){
				$search['keyword']=$_POST['keyword'];
				$where['active_content']=array('like',"%".$_POST['keyword']."%");
			}
		}
		$model=M('');
		$amodel = D('Hawk/Admin');
		if(empty($where)){
			$where=array();
		}	
		//分页
		$count = $model
		->table(C('DB_PREFIX').'operation_log')
		->where($where)
		->order('active_time desc')
		->count();
		$page = new \Think\Page($count, 12);
		// 配置翻页的样式
		$page->setConfig('prev', '上一页');
		$page->setConfig('next', '下一页');
		$page->setConfig('first', '首页');
        $page->setConfig('last', '尾页');
		$list['page'] = $page->show();
		$list['list'] = $model
		->table(C('DB_PREFIX').'operation_log')
		->where($where)
		->order('active_time desc')
		->limit($page->firstRow.','.$page->listRows)
		->select();
		$list['admin']=$model
		->table(C('DB_PREFIX').'admin')
		->select();
		foreach ($list['list'] as $k => $v) {
			$list['list'][$k]['active_name'] = $amodel->getAdminName($v['user_name']);
			$list['list'][$k]['active_time'] = date('Y-m-d H::i:s',$v['active_time']);
		}
		$this->assign('search',$search);
		$this->assign('list',$list);
		$this->display();
	}
}